//1.导入vue-router的函数
import { createRouter, createWebHashHistory } from 'vue-router'

//2. 导入需要跳转的页面组件.
import HomeFrame from '@/views/Home/HomeFrame'
import HomeType from "@/views/HomeType/HomeType"
import HomeList from "@/views/Home/HomeList"
import LoginFrame from '@/views/Login/LoginFrame'
import RegistryFrame from '@/views/Registry/RegistryFrame'
import SpaceFrame from '@/views/Space/SpaceFrame'
import SpacePerson from '@/views/Space/Person/SpacePerson'
import NoteAdd from '@/views/Space/Note/NoteAdd'
import NoteList from '@/views/Space/Note/NoteList'
import NoteDetail from '@/views/Detail/NoteDetail'
import NoteEdit from "@/views/Space/Note/NoteEdit"
import Frame from "@/views/HiLinLin/Frame"



//3. 使用一个数组，定义路由规则
// 每个路由都需要映射到一个组件。
const routes = [{
        path: '/', //ptah是跳转路径
        component: HomeFrame, //component是跳转页面
        hidden: true,
        redirect: '/list', //该属性会当你访问/的时候，跳转到/list路由
        perimission: ['admin', "user"],
        children: [{ //children是子路径
                path: 'list/:noteName?', //?的意思表示notename参数是一个可选参数
                component: HomeList,
                props: true, //启动使用自定义属性接收路由地址的动态参数
                perimission: ['admin', "user"]
            },
            { path: 'type', component: HomeType, perimission: ['admin', "user"] }
        ]
    }, //默认地址展示HomeFrame组件

    { path: '/detail/:noteId', hidden: true, component: NoteDetail, perimission: ['admin', "user"] }, //：noteId表示可以接受一个动态参数
    { path: '/login', hidden: true, component: LoginFrame, perimission: ['admin', "user"] }, //跳转"/login"时展示LoginFrame组件
    { path: '/registry', hidden: true, component: RegistryFrame, perimission: ['admin', "user"] }, //跳转"/registry"时展示RegistryFrame组件
    { path: '/frame', hidden: true, component: Frame, perimission: ['admin', "user"] },


    //{
    // path: '/space',
    // component: SpaceFrame,
    // children: [{
    //         path: "person",
    //         component: SpacePerson
    //     },
    //     {
    //         path: "noteadd",
    //         component: NoteAdd
    //     },
    //     {
    //         path: "mynote",
    //         component: MyNote

    //     },
    //     {
    //         path: "noteedit/:noteId",
    //         component: NoteEdit
    //     },
    //]
    //}
    {
        path: '/note',
        name: "笔记管理",
        hidden: false,
        component: SpaceFrame, //根路由用于展示布局
        perimission: ['admin', "user"],
        children: [{
                path: 'noteadd',
                name: '记笔记',
                hidden: false,
                component: NoteAdd,
                perimission: ['admin', "user"]
            },
            {
                path: 'notelist',
                name: '笔记列表',
                hidden: false,
                component: NoteList,
                perimission: ['admin', "user"]
            },
            {
                path: 'noteedit/:noteId',
                name: '笔记编辑',
                hidden: true,
                component: NoteEdit,
                perimission: ['admin', "user"]
            },
            {
                path: 'notelistall',
                name: '所有笔记',
                hidden: false,
                component: NoteList,
                perimission: ['admin']
            },
        ]
    },
    {
        path: '/person',
        name: '用户管理',
        component: SpaceFrame,
        hidden: false,
        perimission: ['admin', "user"],
        children: [{
            path: 'info', // /person/info
            component: SpacePerson,
            hidden: false,
            name: "个人信息",
            perimission: ['admin', "user"]
        }]
    },

]

// 4. 创建Vue-router实例并传递 `routes` 配置
// 你可以在这里输入更多的配置，但我们在这里
// 暂时保持简单
const router = createRouter({

        // 5. 内部提供了 history 模式的实现。为了简单起见，我们在这里使用 hash 模式。
        history: createWebHashHistory(),
        routes, // 传入routes数组，这一行是简写，是routes: routes的缩写
    })
    //6.默认导出创建好的Vue-router的实例
export default router;